package com.mischa.atc;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/*
 * Represents a traffic controller, issuing commands to aircraft
 * and updating the radar screen
 */
public class Controller {
	List<Flight> _flights;
	
	public Controller() {
		_flights = new ArrayList<Flight>();
	}
	
	public Flight addFlight()
	{
		Aircraft aircraft = new Aircraft();
		aircraft.setSpeed(250);
		aircraft.setHeading((float)Math.random() * 360);
		
		Flight newFlight = new Flight(aircraft);
		_flights.add(newFlight);
		
		return newFlight;
	}
	

	public void removeFlight(Flight flight) {
		_flights.remove(flight);
	}
	
	public int countFlights()
	{
		return _flights.size();
	}
	
	public Iterator<Flight> getIterator()
	{
		return _flights.iterator();
	}
	
}
